﻿/********************************************************************************/
// <copyright file="BlocksFactory.cs" company="Asia E-Business Solutions">
//     Copyright © 2012. All right reserved
// </copyright>
//
// <history>
//  <change who="Hieu Nguyen" date="11/12/2012 2:38:07 PM">Created</change>
// <history>
/********************************************************************************/

namespace JLL.China.Infrastructure.Repositories.Blocks
{
    using System.Collections.Generic;
    using LINQ = JLL.China.Infrastructure.Repositories.LINQ2SQL;
    using JLL.China.Model;

    public static class BlocksFactory
    {
        public static Model.Blocks FromLINQObject(LINQ.lkup_block blocks)
        {
            if (blocks == null)
            {
                return null;
            }
            else
            {
                var model = new Model.Blocks
                {
                    ID = (int)blocks.idstaticblock,
                    Title = blocks.title,
                    Slug = blocks.slug,
                    BlockContent = blocks.block_content,
                    SystemBlock = blocks.system_block,
                    Status = blocks.status
                };
                return model;
            }
        }
        //
        public static LINQ.lkup_block ToLINQObject(Model.Blocks newsItem)
        {
            var model = new LINQ.lkup_block
            {
                idstaticblock = newsItem.ID,
                title = newsItem.Title,
                slug = newsItem.Slug,
                block_content = newsItem.BlockContent,
                system_block = newsItem.SystemBlock,
                status = newsItem.Status
            };
            
            return model;
        }
    }
}
